home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Franz PD / Franz PD Disk #009 (19xx)(Amiga User Group Deutschland e.V.).zip / Franz PD Disk #009 (19xx)(Amiga User Group Deutschland e.V.).adf / ScreenShift / math.s < prev    next >
Text File  |  1986-10-22  |  2KB  |  59 lines

  1. ;**********************************************************************
  2. ; Math routines for converting HorizPot/VertPot values
  3. ; to and from ViewXOffset/ViewYOffset values
  4. ; (I don't want to do it in C!)
  5. ; Anson Mah
  6. ;
  7. ; Declarations:
  8. ;  extern UWORD xoffset(BYTE), yoffset(BYTE);
  9. ;  extern BYTE xpot(UWORD), ypot(UWORD);
  10. ;**********************************************************************
  11. ;
  12. MAXXOFFSET    equ    $003f
  13. MAXYOFFSET    equ    $001f
  14. HALFBODY    equ    $7ffe    ; MAXBODY / 2
  15. ;
  16.     xdef    _xoffset
  17.     xdef    _yoffset
  18.     xdef    _xpot
  19.     xdef    _ypot
  20. ;
  21. ;**********************************************************************
  22. ; _xoffset and _yoffset to convert from offset to pot value
  23. ;**********************************************************************
  24. ;
  25. _xoffset
  26.     move.l    #MAXXOFFSET,d1    ; load maximum x offset value
  27.     bra.s    offs        ; jump to offset routine
  28. _yoffset
  29.     move.l    #MAXYOFFSET,d1    ; load maximum y offset value
  30. ;
  31. offs    move.l    4(sp),d0    ; get ViewOffset value
  32.     muls    #HALFBODY,d0
  33.     divs    d1,d0        ; divide by maximum offset value
  34.     addi.w    #HALFBODY,d0
  35.     rts            ; return result in d0
  36. ;
  37. ;**********************************************************************
  38. ; _xpot and _ypot to convert from pot to offset value
  39. ;**********************************************************************
  40. ;
  41. _xpot
  42.     move.l    #MAXXOFFSET,d1    ; load maximum x offset value
  43.     bra.s    pot        ; jump to pot routine
  44. _ypot
  45.     move.l    #MAXYOFFSET,d1    ; load maximum y offset value
  46.  
  47. pot    move.l    4(sp),d0    ; get pot value
  48.     beq.s    1$
  49.     subi.w    #1,d0        ; subtract two if not zero (kludge)
  50.     beq.s    1$
  51.     subi.w    #1,d0
  52. 1$    subi.w    #HALFBODY,d0
  53.     muls    d1,d0        ; multiply by maximum offset value
  54.     divs    #HALFBODY,d0
  55.     rts            ; return result in d0
  56. ;
  57. ;**********************************************************************
  58.     end
  59.